using System;
using JNPF.Basics.Models;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using JNPF.Utils;
using System.Transactions;

namespace JNPF.Basics.Logic
{
    public class jiushiZzhuserBll
    {
        private jiushiZzhuserIService service = new jiushiZzhuserService();


        /// <summary>
        /// 获取信息
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns></returns>
        public async Task<jiushiZzhuserEntity> GetInfo(string id)
        {
            try
            {
                return await service.GetInfo(id);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }


        /// <summary>
        /// 根据公众号ID获取用户
        /// </summary>
        /// <param name="openId"></param>
        /// <returns></returns>
        public async Task<jiushiZzhuserEntity> GetInfoByOpenid(string openId)
        {
            try
            {
                return await service.GetInfoByOpenid(openId);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 根据小程序ID获取用户
        /// </summary>
        /// <param name="xcxOpenId"></param>
        /// <returns></returns>
        public async Task<jiushiZzhuserEntity> GetInfoByXcxOpenId(string xcxOpenId)
        {
            try
            {
                return await service.GetInfoByXcxOpenId(xcxOpenId);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 根据UUID获取用户ID
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        public async Task<jiushiZzhuserEntity> GetInfoByuuid(string uuid)
        {
            try
            {
                return await service.GetInfoByuuid(uuid);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 根据userId获取用户ID
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task<jiushiZzhuserEntity> GetInfoByUserId(string userId)
        {
            try
            {
                return await service.GetInfoByUserId(userId);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }


        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="input">请求参数</param>
        /// <returns></returns>
        public async Task<PageResult<jiushiZzhuserEntity>> GetPageList(jiushiZzhuserListQueryInput input)
        {
            try
            {
                return await service.GetPageList(input);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 创建信息
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public async Task<int> Create(jiushiZzhuserEntity entity)
        {
            try
            {
                entity.Id = CommonHelper.Guid;
                entity.CreatorTime = DateTime.Now;
                return await service.Create(entity);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 更新信息
        /// </summary>
        /// <param name="id">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public async Task<int> Update(string id, jiushiZzhuserEntity entity)
        {
            try
            {
                entity.Id = id;
                return await service.Update(entity);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public async Task<int> Delete(jiushiZzhuserEntity entity)
        {
            try
            {
                return await service.Delete(entity);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="input">过滤条件</param>
        /// <returns></returns>
        public async Task<List<jiushiZzhuserEntity>> GetList(jiushiZzhuserListQueryInput input)
        {
            try
            {
                return await service.GetList(input);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }



        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="input">请求参数</param>
        /// <returns></returns>
        public async Task<List<jiushiZzhuserEntity>> GetListByType(int type)
        {
            try
            {
                return await service.GetListByType(type);
            }
            catch (Exception ex)
            {
                throw ExceptionEx.Throw(ex);
            }
        }

    }
}